package com.water.app.Impl.account;

import com.water.app.User;
import com.water.app.interfaces.account.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.water.app.mapper.userMapper;

@Service
public class RegisterServiceImpl implements RegisterService {
    @Autowired
    private userMapper userMapper;

    //验证账号是否符合规范
    @Override
    public boolean verifyUsername(String username) {
        //TODO
        return userMapper.selectUserByUsername(username)!=null;
    }

    //验证账号是否存在
    @Override
    public boolean AccountIsExist(String username) {
        //TODO
        if (username == null) {
            return false;
        }
        //用户名不存在
        if(userMapper.selectUserByUsername(username)==null){
            return false;
        }
        return true;
    }

    @Override
    public boolean verifyPassword(String password) {
        //TODO
        return true;
    }

    @Override
    public boolean verifyEmail(String email) {
        return userMapper.selectEmail(email) <= 0;
    }

    @Override
    public boolean verifyAccount(String account) {return userMapper.selectUserByAccount(account)!=null;}

    @Override
    public boolean registerUser(User user) {
        return userMapper.insertUser(user)>0;
    }

    @Override
    public boolean reviseUser(User user) {
        return userMapper.reviseUser(user)>0;
    }
}
